﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Scheduling.Models.Interfaces;

namespace Scheduling.Models.Helpers
{
    public class CourseInstanceHelper
    {

        public static List<SelectListItem> GetCourseInstances()
        {
            var courseInstanceLoader = IoC.Resolve<ICourseInstanceLoader>();
            List<CourseInstance> courseInstances = courseInstanceLoader.GetCourseInstances();

            var courseInstanceList = new List<SelectListItem>();

            foreach (CourseInstance c in courseInstances)
            {
                courseInstanceList.Add(new SelectListItem() { Text = c.ID.ToString()+" (year: "+c.Year.ToString()+")", Value = c.ID.ToString() });
            }

            return courseInstanceList.OrderBy(c => c.Text).ToList();
        }
    } 
}